/**
 * @author baz
 */
package mvc {
import bot.BotView;
import bot.weapon.WeaponEvent;

import flash.display.DisplayObjectContainer;
import flash.display.StageDisplayState;

import mvc.controller.AppCmd;
import mvc.controller.FireBallShotCmd;
import mvc.model.GameModel;
import mvc.view.BotViewMediator;
import mvc.view.MainViewMediator;

import org.robotlegs.base.ContextEvent;
import org.robotlegs.mvcs.Context;

public class App extends Context {

    public function App(contextView:DisplayObjectContainer) {
        super(contextView);
    }

    override public function startup():void {
        // ============= Старт приложения =============
        commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, AppCmd, ContextEvent, true);
//        commandMap.mapEvent(SocialNetworkServiceEvent.INIT_SUCCESS, SnApiCreationSuccess);
//        commandMap.mapEvent(SocialNetworkServiceEvent.CHECK_SETTINGS_SUCCESS, SnSettingsSuccess);
//        commandMap.mapEvent(SocialNetworkServiceEvent.SELF_PROFILE_SUCCESS, SnUserProfileSuccess);
//        commandMap.mapEvent(SocialNetworkServiceEvent.APP_FRIENDS_PROFILES_SUCCESS, SnAppFriendsProfilesSuccess);
//        commandMap.mapEvent(SocialNetworkServiceEvent.FRIENDS_PROFILES_SUCCESS, SnFriendsProfilesSuccess);
//        commandMap.mapEvent(XWarsServerProxyEvent.INIT_SUCCESS, SrvInitSuccessHandler, XWarsServerProxyEvent);
//        commandMap.mapEvent(AssetManagerEvent.ALL_LOADED, AssetSuccessHandler, AssetManagerEvent, true);
//
//        // ============= События ошибок =============
//        commandMap.mapEvent(SocialNetworkServiceEvent.INIT_ERROR, SnRequestErrorHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(SocialNetworkServiceEvent.SELF_PROFILE_ERROR, SnRequestErrorHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(SocialNetworkServiceEvent.APP_FRIENDS_PROFILES_ERROR, SnRequestErrorHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(XWarsServerProxyEvent.INIT_ERROR, SrvRequestErrorHandler, XWarsServerProxyEvent);
//        commandMap.mapEvent(XWarsServerProxyEvent.SYNC_ERROR, SrvSyncErrorHandler, XWarsServerProxyEvent);
//        commandMap.mapEvent(XWarsServerProxyEvent.SYNC_IO_ERROR, SrvSyncIOErrorCmd, XWarsServerProxyEvent);
//        commandMap.mapEvent(ErrorEvent.GAME_ERROR, HandleErrorCmd, GameEvent);
//        commandMap.mapEvent(ErrorEvent.UNHANDLED_ERROR, HandleErrorCmd, GameEvent);
//
//        // ============= Синхронизация =============
//        commandMap.mapEvent(UserEvent.ATTR_CHANGE, SrvDoSyncHandler, XWarsEvent);
//        commandMap.mapEvent(XWarsServerProxyEvent.SYNC_DO_FORCE, SrvDoForceSyncHandler, XWarsServerProxyEvent);
//
//        // ============= Социальное взаимодействие =============
//        commandMap.mapEvent(SocialNetworkServiceEvent.INVITE_FRIENDS, SnInviteFriendsHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(SocialNetworkServiceEvent.TELL_FRIENDS, SnTellFriendsHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(SocialNetworkServiceEvent.POST_PHOTO, SnPostPhotoHandler, SocialNetworkServiceEvent);
//        commandMap.mapEvent(GameEvent.SHOW_LEADER_DIALOG, ShowLeaderDialogHandler, GameEvent);
//        commandMap.mapEvent(GameEvent.PRE_VISIT_USER, PreVisitUserCmd, GameEvent);
//
//        // ============= Туториальные события =============
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_CHECK, TutorialCheckHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_SKIP, TutorialSkipHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_START, TutorialStartHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_WASH_NEED, TutorialWashNeedHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_SETUP_SATISFY_PLACES, TutorialSetupSatisfyPlacesHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_BUY_BATHROOM, TutorialBathBuyHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_FAINA_SKIP, TutorialFainaSkipHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_FAINA_END, TutorialFainaEndStepHandler, GameEvent);
//        commandMap.mapEvent(TutorialEvent.TUTORIAL_END, TutorialEndStepHandler, GameEvent);
//
//
//        // ============= События диалогов =============
//        commandMap.mapEvent(GameEvent.SHOW_NEW_CHILD_DIALOG, ShowNewChildDialogCmd, GameEvent);
//        commandMap.mapEvent(GameEvent.SHOW_NOT_ENOUGH_MONEY_DLG, NotEnoughMoneyHandler, GameEvent);
//        commandMap.mapEvent(GameEvent.SHOW_NOT_ENOUGH_ENERGY_DLG, NotEnoughEnergyHandler, GameEvent);
//
//        // ============= Игровой процесс =============
        commandMap.mapEvent(WeaponEvent.FIREBALL_SHOT, FireBallShotCmd, WeaponEvent);

//        // ============= События бабая =============
//        commandMap.mapEvent(BoogeymanEvent.SHOW_BOOGEYMAN, ShowBoogeymanCmd, BoogeymanEvent);
//        commandMap.mapEvent(BoogeymanEvent.BOOGEYMAN_EXPELLED, ExpelledBoogeymanCmd, BoogeymanEvent);
//        commandMap.mapEvent(ChildEvent.KIDS_ARRANGED, CheckBoogeymanCmd, GameEvent);
//
//        // ============= Награды =============
//        commandMap.mapEvent(UserEvent.CLIENT_REWARD, UserClientRewardCmd, XWarsEvent);
//        commandMap.mapEvent(DropperEvent.DROP_MODIFY_REWARD, DropModifyRewardCmd, DropperEvent);
//        commandMap.mapEvent(DropperEvent.DROP_ITEM_REWARD, DropItemRewardCmd, DropperEvent);
//        mediatorMap.mapView(Reward, RewardMediator);
//
//        // ============= Пользователь =============
//        commandMap.mapEvent(UserEvent.CLIENT_LEVEL_UP, LevelUpCmd, XWarsEvent);
//
//        // ============= Комбо бонусы =============
//        commandMap.mapEvent(ErrorEvent.RE_INIT_USER_BY_SYNC, ReInitUserBySyncCmd, GameEvent);
//        commandMap.mapEvent(GameEvent.CHECK_DISCOUNT_AND_BONUS, DiscountAndBonusChecker, GameEvent, true);
//
//        // ============= Предметы интерьера =============
//        commandMap.mapEvent(InteriorEvent.TOGGLE_INTERIOR_ACTION_MENU, ToggleInteriorActionMenuHandler, InteriorEvent); // Вкл\выкл интерьерное экшон-меню
//        commandMap.mapEvent(InteriorEvent.TOGGLE_GRID_VIEW, ToggleGridViewHandler, InteriorEvent);
//        commandMap.mapEvent(InteriorEvent.INTERIOR_MOVE, InteriorMoveHandler, InteriorEvent);
//        commandMap.mapEvent(InteriorEvent.INTERIOR_BUY, InteriorBuyHandler, InteriorEvent);
//
//        // ============= Синглтоны =============
//        injector.mapSingleton(Actions);
//        injector.mapSingleton(AppModel);
        injector.mapSingleton(GameModel);
//        injector.mapSingleton(GlobSettings);
//
//        // ============= Сервисы =============
//        injector.mapSingletonOf(ISocialNetworkService, SocialNetworkService);
//
//        // ============= Медик главной вьюхи =============
        mediatorMap.mapView(MainView, MainViewMediator);

        mediatorMap.mapView(BotView, BotViewMediator);
//
//        // ============= Игровые экраны =============
//        mediatorMap.mapView(LoadScreen, LoadScreenMediator);
//        mediatorMap.mapView(GameScreen, GameScreenMediator);
//
//
//        // ============= Панели =============
//        mediatorMap.mapView(FooterPanel, FooterPanelMediator);
//
//        // ============= Меню действий =============
//        mediatorMap.mapView(ChildActionMenu, ChildActionMenuMediator);          // Экшон-меню для детей
//        mediatorMap.mapView(InteriorActionMenu, InteriorActionMenuMediator);    // Экшон-меню для интерьеров
//
//        // ============= Widjets =============
//        mediatorMap.mapView(GardenSignboard, GardenSignboardMediator);
//        mediatorMap.mapView(Secret, SecretMediator);
//        mediatorMap.mapView(Boogeyman, BoogeymanMediator);
//
//        // ============= Диалоги =============
//        mediatorMap.mapView(BuyCashDrgDlg, BuyCashDrgDlgMediator);
//
//
//        // Коллекции
//        mediatorMap.mapView(CollectionDlg, CollectionDlgMediator);
//        mediatorMap.mapView(CollectionWidget, CollectionWidgetMediator);
//        mediatorMap.mapView(CollectionDlgWidget, CollectionDlgWidgetMediator);
//
//        commandMap.mapEvent(CollectionEvent.SHOW_COLLECTION_WIDGET, ShowCollectionWidgetCmd, CollectionEvent);
//        commandMap.mapEvent(CollectionEvent.SHOW_COLLECTION_DLG, ShowCollectionDlgCmd, CollectionEvent);
//        commandMap.mapEvent(CollectionEvent.GET_COLLECTION_REWARD, CollectionRewardGetCmd, CollectionEvent);
//        commandMap.mapEvent(KinderEvent.COLLECTION_ITEM_ADD, CollectionItemAddCmd, XWarsEvent);
//        injector.mapSingleton(CollectionProxy);


        contextView.addChild(new MainView);
        super.startup();
    }
}
}